package com.messagers
{
	import flash.filesystem.File;
	
	import starling.textures.Texture;
	import starling.utils.AssetManager;
	import com.AppConfing;

	/**
	 * 加载编辑器界面所有用到的资源管理 
	 * @author shishujun
	 * 
	 */	
	public class AppLoadExportUISkin
	{
		private static var BGTEXTURE: Texture;
		private static var BTNTEXTURE : Texture;			//按钮图标
		private static var IMGTEXTURE : Texture;			//图片图标
		private static var S9TEXTURE  : Texture;			//s9图标
		
		private static var _BasecomponentData : Array;
		
		private static const uiimgurl : String = "/assets/images/exportimg";	//	编辑器用图标文件夹路径
		
		private static var file : File;
		private static var assetManager : AssetManager;
		
		private static var assetsLoadComplete : Function;
		
		public function AppLoadExportUISkin()
		{
			
		}
		
		/**
		 * 加载编辑器图标资源 
		 * @param loadComplete
		 * 
		 */		
		public static function loadExportAssets(loadComplete : Function) : void
		{
			var str : String = AppConfing.SwfUrl + uiimgurl;
			var f : File = new File(str);
			
			assetManager = new AssetManager();
			assetManager.enqueue(f);
			assetManager.loadQueue(onprogress);
			
			assetsLoadComplete = loadComplete ;
		}
		
		/**
		 * 加载编辑器组件图标的文件夹资源。 
		 * @param ratio
		 * 
		 */		
		private static function onprogress(ratio:Number) : void
		{
			if(ratio == 1)
			{
				BGTEXTURE = assetManager.getTexture("bg");
				BTNTEXTURE = assetManager.getTexture("btn");
				IMGTEXTURE = assetManager.getTexture("img");
				S9TEXTURE = assetManager.getTexture("s9");
				
				basecomponentData();
				assetsLoadComplete();
			}
		}
		
		/**获取背景纹理
		 * @return **/
		public static function get BgTexture() : Texture
		{
			return BGTEXTURE;
		}
		
		/**获取按钮图标纹理
		 * @return **/
		public static function get BtnTexture() : Texture
		{
			return BTNTEXTURE;
		}
		
		/**获取图片图标纹理
		 * @return **/
		public static function get ImgTexture() : Texture
		{
			return IMGTEXTURE;
		}
		
		/**获取9宫格图片纹理
		 * @return **/
		public static function get S9Texture() : Texture
		{
			return S9TEXTURE;
		}
		
		public static function get BasecomponentData() : Array
		{
			return _BasecomponentData;
		}
		
		/**
		 * 基础组件栏显示各组件的数据 
		 * @return 
		 * 
		 */		
		private static function basecomponentData() : void
		{
			var arr : Array = [
				{texture : BtnTexture , name : "Button"},
				{texture : ImgTexture , name : "Image"},
				{texture : S9Texture , name : "S9Image"}
			];
			_BasecomponentData = arr;
		}
	}
}